import Taro from '@tarojs/taro'
import { View, Text, Image } from '@tarojs/components'

import './index.scss'

export default ({ productList = [] }) => {
  const goProductDetail = (item: any) => {
    Taro.navigateTo({
      url: `/pages/product_detail/index?id=${item.id}`,
    })
  }

  return (
    <View className="product-wrapper at-row at-row__justify--between at-row--wrap">
      {productList.map((item: any) => (
        <View
          className="item"
          key={item.id}
          onClick={() => goProductDetail(item)}
        >
          <Image src={item.image}></Image>
          <View className="info">
            <View className="name line1">{item.storeName}</View>
            {/* <View className="old-price">
              <Text>¥</Text>
              {item.otPrice}
            </View> */}
            <View className="price price-color">
              <Text>￥</Text>
              {item.price}
            </View>
          </View>
        </View>
      ))}
    </View>
  )
}
